<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/base.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="${ctsCss}/table.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<%@ include file="/common/message-save-formula.jsp"%>
<body>

	<form id="hang-form" class="form-horizontal"
		action="${ctx}/reportTemplateCountController/saveHangCount" method="post">
		<input type="hidden" id="templateId" name="templateId" value="${templateId}" />
		<input type="hidden" id="areaTemporaryId" name="areaTemporaryId"/>
		
			<div>
	       				<span style="color:red">注：行计算公式需要严格按照指定方式填写，如不按指定方式填写将不会生成相应计算公式</span>
	       				<span style="color:red">填写规则：1)1栏=2栏+3栏+4栏，对应填写为1=2+3+4;2)1栏=2栏+3栏+4栏至6栏之和，对应填写为1=2+3+4~6</span>
	       			</div>
		<table>
			<tr class="tab_grey">
				<td width="30%">数据区域选择</td>
				<td>
					<select id="chooseDataAreaSelectId" name="chooseDataAreaSelectName" class="chooseDataAreaSelectClass" onchange="assignmentAreaId();" required></select>
				</td>
			</tr>

			<tr class="tab_grey">
				<td width="30%">公式</td>
				<td><textarea rows="3" cols="70" id="calcFormulaShow"
						name="calcFormulaShow" value="${rptTemplateCalc.calcFormulaShow }" required></textarea></td>
			</tr>
			<tr class="tab_grey">
				<td width="30%">序号</td>
				<td width="70%" colspan="3">
				<input type="text" id="orderId"
					name="orderId" value="${rptTemplateCalc.orderId }" required
					style="width: 200px" maxlength='100' /></td>
			</tr>
		</table>
		<div style="text-align: center;">
			<button type="button" class="btn btn-primary" id="saveBtn"
				onclick="add();">保存</button>
		</div>
	</form>

</body>

<script type="text/javascript">
$('#hang-form').validate();
	function add() {
		$("#hang-form").submit();
	}
	
	function onloadReportTemporary(){
		var templateId = $("#templateId").val();
		$.ajax({
			url:'${ctx}/reportDesignController/queryReportAreaTemporary/'+templateId,
			type:'POST',
			cache:false,
			success:function(data){
				var treeSelectIdOptions = "";
			    $.each(data,function(idx,item){
			    	treeSelectIdOptions += "<option value='"+item.id+"'>" + item.temporaryDescribe + "</option>";
				});
			    $("#chooseDataAreaSelectId option").remove();
			    treeSelectIdFirst="<option value='0'>请选择</option>";
			    $(".chooseDataAreaSelectClass").append(treeSelectIdFirst).append(treeSelectIdOptions);
			}
		});
	}
	
	$(document).ready(function(){//初始化
		onloadReportTemporary();
	});
	function assignmentAreaId(){
		var chooseDataAreaSelectId = $("#chooseDataAreaSelectId").val();
		$("#areaTemporaryId").val(chooseDataAreaSelectId);
	}
</script>
</html>